HomeGames.tsx 712 B

123456789101112131415161718192021222324
  1. "use client";
  2. import { getGamesApi, GroupType } from "@/api/home";
  3. import { SwiperGroup } from "@/components/Card";
  4. import { FC, PropsWithChildren, useEffect, useState } from "react";
  5. import "swiper/css";
  6. interface Props {}
  7. const HomeSwiper: FC<PropsWithChildren<Props>> = (props) => {
  8. const [groupGames, setGroupGames] = useState<GroupType[]>([]);
  9. useEffect(() => {
  10. getGamesApi().then((res) => {
  11. setGroupGames(res.data);
  12. });
  13. }, []);
  14. return (
  15. <div>
  16. {!!groupGames &&groupGames.map((group, index) => {
  17. return <SwiperGroup key={index} group={group}></SwiperGroup>;
  18. })}
  19. </div>
  20. );
  21. };
  22. export default HomeSwiper;